package com.example.cpms.service.impl;

import com.example.cpms.entity.Building;
import com.example.cpms.entity.RodManage;
import com.example.cpms.mapper.RodManageMapper;
import com.example.cpms.service.RodManageService;
import com.example.cpms.utils.PageBean;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RodManageServicempl implements RodManageService {

    @Autowired
    private RodManageMapper rodManageMapper;

    /**
     * 分页
     * @param page
     * @param pageSize
     * @param poleName
     * @param poleNumber
     * @param poleStatus
     * @return
     */
    @Override
    public PageBean page(Integer page, Integer pageSize, String poleName,String poleNumber, Integer poleStatus) {
        PageHelper.startPage(page,pageSize);
        List<RodManage> rodManagesList = rodManageMapper.list(poleName, poleNumber, poleStatus);
        Page<RodManage> p = (Page<RodManage>) rodManagesList;
        PageBean pageBean = new PageBean(p.getTotal(),p.getResult());
        return pageBean;
    }

    /**
     * 根据id删除
     * @param id
     */
    @Override
    public void delete(Integer id) {
        rodManageMapper.delete(id);
    }

    /**
     * 添加一体杆
     * @param rodManage
     */
    @Override
    public void add(RodManage rodManage) {
      //  rodManage.setPoleStatus(0);
        rodManageMapper.insert(rodManage);
    }

    /**
     * 更新一体杆
     * @param rodManage
     */
    @Override
    public void update(RodManage rodManage) {
        rodManageMapper.update(rodManage);
    }
}
